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

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

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

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

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

b.u = m
m.v = j
m.r = j
f.u = a
f.v = j
c.x = j
c.o = f
c.w = m
j.x = c
j.o = f
j.w = m
e.v = c
e.r = j
a.v = j
a.r = c
assert f.u.r.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

b.u = m
m.v = j
m.r = j
f.u = a
f.v = j
c.x = j
c.o = f
c.w = m
j.x = c
j.o = f
j.w = m
e.v = c
e.r = j
a.v = j
a.r = c
assert f.u.r.o.v.txt == "j"