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

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

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

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

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

a.t = l
a.o = m
f.s = n
f.p = i
n.o = b
n.x = b
n.v = a
b.q = m
b.o = i
m.q = b
m.o = i
l.s = n
l.p = a
i.t = f
i.o = m
assert a.t.p.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

a.t = l
a.o = m
f.s = n
f.p = i
n.o = b
n.x = b
n.v = a
b.q = m
b.o = i
m.q = b
m.o = i
l.s = n
l.p = a
i.t = f
i.o = m
assert a.t.p.o.q.txt == "b"