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

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

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

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

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

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

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

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

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

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

l.q = f
l.z = f
l.p = j
g.x = f
g.p = k
j.u = d
f.z = m
f.y = m
f.p = d
d.u = j
k.q = f
k.z = f
k.p = j
m.q = f
m.z = f
m.p = j
b.x = f
b.p = k
h.x = f
h.p = k
assert f.z.q.y.txt == "m"