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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
b = C("b")
i = D("i")
c = D("c")
k = D("k")
d = C("d")

f.z = i
f.u = i
f.q = c
h.x = f
h.r = c
b.s = c
b.q = h
b.r = k
i.u = h
i.y = k
i.v = f
c.u = h
c.y = i
c.v = f
k.u = h
k.y = c
k.v = f
d.s = c
d.q = h
d.r = k
assert h.r.u.r.y.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: D = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.txt = txt

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

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

f = A("f")
h = B("h")
b = C("b")
i = D("i")
c = D("c")
k = D("k")
d = C("d")

f.z = i
f.u = i
f.q = c
h.x = f
h.r = c
b.s = c
b.q = h
b.r = k
i.u = h
i.y = k
i.v = f
c.u = h
c.y = i
c.v = f
k.u = h
k.y = c
k.v = f
d.s = c
d.q = h
d.r = k
assert h.r.u.r.y.y.y.u.txt == "h"