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

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
g = C("g")
h = D("h")
b = B("b")
n = D("n")
d = C("d")
m = D("m")
k = B("k")
j = B("j")

e.y = n
e.t = n
e.r = d
f.z = j
f.r = j
g.p = e
h.y = e
h.q = k
b.z = k
b.r = f
n.y = e
n.q = j
d.p = e
m.y = e
m.q = f
k.z = b
k.r = j
j.z = f
j.r = k
assert h.q.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: D = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.txt = txt

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

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

e = A("e")
f = B("f")
g = C("g")
h = D("h")
b = B("b")
n = D("n")
d = C("d")
m = D("m")
k = B("k")
j = B("j")

e.y = n
e.t = n
e.r = d
f.z = j
f.r = j
g.p = e
h.y = e
h.q = k
b.z = k
b.r = f
n.y = e
n.q = j
d.p = e
m.y = e
m.q = f
k.z = b
k.r = j
j.z = f
j.r = k
assert h.q.z.z.txt == "k"