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

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

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

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

f = A("f")
l = B("l")
i = C("i")
b = D("b")
m = C("m")
c = D("c")

f.o = l
f.x = l
l.y = f
l.u = f
l.x = f
i.s = m
i.t = c
b.y = l
b.x = l
b.p = l
b.w = f
m.s = i
m.t = b
c.y = l
c.x = l
c.p = l
c.w = f
assert i.t.y.y.x.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.txt = txt

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

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

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

f = A("f")
l = B("l")
i = C("i")
b = D("b")
m = C("m")
c = D("c")

f.o = l
f.x = l
l.y = f
l.u = f
l.x = f
i.s = m
i.t = c
b.y = l
b.x = l
b.p = l
b.w = f
m.s = i
m.t = b
c.y = l
c.x = l
c.p = l
c.w = f
assert i.t.y.y.x.y.o.txt == "l"