class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: C = None
        self.w: B = None
        self.z: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.w: B = None
        self.txt = txt

m = A("m")
l = B("l")
b = C("b")
j = D("j")
k = B("k")
g = A("g")
n = D("n")
a = B("a")
c = B("c")
h = C("h")

m.y = h
m.t = g
l.q = m
l.y = h
l.w = c
l.z = c
b.p = l
b.q = k
j.p = h
j.z = b
j.w = k
k.q = g
k.y = h
k.w = c
k.z = a
g.y = b
g.t = m
n.p = b
n.z = b
n.w = k
a.q = g
a.y = b
a.w = c
a.z = c
c.q = m
c.y = h
c.w = a
c.z = a
h.p = a
h.q = l
assert c.w.y.q.z.q.t.y.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: C = None
        self.w: B = None
        self.z: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.w: B = None
        self.txt = txt

m = A("m")
l = B("l")
b = C("b")
j = D("j")
k = B("k")
g = A("g")
n = D("n")
a = B("a")
c = B("c")
h = C("h")

m.y = h
m.t = g
l.q = m
l.y = h
l.w = c
l.z = c
b.p = l
b.q = k
j.p = h
j.z = b
j.w = k
k.q = g
k.y = h
k.w = c
k.z = a
g.y = b
g.t = m
n.p = b
n.z = b
n.w = k
a.q = g
a.y = b
a.w = c
a.z = c
c.q = m
c.y = h
c.w = a
c.z = a
h.p = a
h.q = l
assert c.w.y.q.z.q.t.y.p.q.txt == "g"