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

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

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

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

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

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

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

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

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

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

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