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

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

class C:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: D = None
        self.txt = txt

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

d = A("d")
h = B("h")
m = C("m")
e = D("e")
b = B("b")
j = A("j")
c = A("c")
g = C("g")

d.y = j
d.z = c
d.u = c
d.q = h
h.u = e
h.x = m
h.q = b
m.s = g
m.t = e
e.t = j
b.u = e
b.x = g
b.q = h
j.y = d
j.z = d
j.u = c
j.q = b
c.y = d
c.z = j
c.u = j
c.q = b
g.s = m
g.t = e
assert h.u.t.q.q.q.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.u: A = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: D = None
        self.txt = txt

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

d = A("d")
h = B("h")
m = C("m")
e = D("e")
b = B("b")
j = A("j")
c = A("c")
g = C("g")

d.y = j
d.z = c
d.u = c
d.q = h
h.u = e
h.x = m
h.q = b
m.s = g
m.t = e
e.t = j
b.u = e
b.x = g
b.q = h
j.y = d
j.z = d
j.u = c
j.q = b
c.y = d
c.z = j
c.u = j
c.q = b
g.s = m
g.t = e
assert h.u.t.q.q.q.u.t.u.txt == "c"