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

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

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

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

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

d.x = g
a.o = f
a.u = n
a.y = j
f.z = d
f.p = g
f.x = j
k.q = f
j.o = f
j.u = a
j.y = a
c.x = d
g.x = c
b.q = f
n.o = f
n.u = j
n.y = a
m.x = d
assert n.y.u.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

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

d.x = g
a.o = f
a.u = n
a.y = j
f.z = d
f.p = g
f.x = j
k.q = f
j.o = f
j.u = a
j.y = a
c.x = d
g.x = c
b.q = f
n.o = f
n.u = j
n.y = a
m.x = d
assert n.y.u.y.o.txt == "f"