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

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

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

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

i = A("i")
h = B("h")
j = C("j")
a = D("a")
f = C("f")
b = B("b")
e = B("e")

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

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

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

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

i = A("i")
h = B("h")
j = C("j")
a = D("a")
f = C("f")
b = B("b")
e = B("e")

i.u = e
i.r = a
h.v = i
h.w = i
h.r = a
h.z = e
j.y = h
j.w = b
j.x = e
a.o = i
f.y = b
f.w = e
f.x = e
b.v = i
b.w = i
b.r = a
b.z = h
e.v = i
e.w = i
e.r = a
e.z = h
assert b.z.r.o.r.o.txt == "i"