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

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

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

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

e = A("e")
f = B("f")
a = C("a")
g = D("g")
j = C("j")
i = D("i")
m = B("m")
c = B("c")
b = C("b")

e.u = b
f.p = i
f.v = b
a.y = e
a.w = m
a.x = b
g.q = f
g.p = m
g.o = i
j.y = e
j.w = m
j.x = b
i.q = f
i.p = c
i.o = g
m.p = g
m.v = a
c.p = i
c.v = b
b.y = e
b.w = m
b.x = a
assert a.x.w.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

e = A("e")
f = B("f")
a = C("a")
g = D("g")
j = C("j")
i = D("i")
m = B("m")
c = B("c")
b = C("b")

e.u = b
f.p = i
f.v = b
a.y = e
a.w = m
a.x = b
g.q = f
g.p = m
g.o = i
j.y = e
j.w = m
j.x = b
i.q = f
i.p = c
i.o = g
m.p = g
m.v = a
c.p = i
c.v = b
b.y = e
b.w = m
b.x = a
assert a.x.w.p.q.txt == "f"