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

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

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

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

b = A("b")
j = B("j")
d = C("d")
c = D("c")
n = D("n")
f = A("f")
a = C("a")
h = D("h")

b.p = a
b.z = n
b.y = n
j.p = f
j.s = b
d.r = j
d.q = j
d.x = a
d.u = b
c.o = a
c.r = j
c.p = j
n.o = d
n.r = j
n.p = j
f.p = d
f.z = c
f.y = h
a.r = j
a.q = j
a.x = d
a.u = b
h.o = d
h.r = j
h.p = j
assert c.o.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: D = None
        self.y: D = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
d = C("d")
c = D("c")
n = D("n")
f = A("f")
a = C("a")
h = D("h")

b.p = a
b.z = n
b.y = n
j.p = f
j.s = b
d.r = j
d.q = j
d.x = a
d.u = b
c.o = a
c.r = j
c.p = j
n.o = d
n.r = j
n.p = j
f.p = d
f.z = c
f.y = h
a.r = j
a.q = j
a.x = d
a.u = b
h.o = d
h.r = j
h.p = j
assert c.o.q.p.txt == "f"