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

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

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

l = A("l")
n = B("n")
d = C("d")
b = A("b")
h = A("h")
c = B("c")
a = B("a")

l.o = h
l.p = h
l.t = h
n.v = d
d.x = c
b.o = h
b.p = h
b.t = l
h.o = b
h.p = l
h.t = l
c.v = d
a.v = d
assert n.v.x.v.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.p: A = None
        self.t: A = None
        self.txt = txt

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

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

l = A("l")
n = B("n")
d = C("d")
b = A("b")
h = A("h")
c = B("c")
a = B("a")

l.o = h
l.p = h
l.t = h
n.v = d
d.x = c
b.o = h
b.p = h
b.t = l
h.o = b
h.p = l
h.t = l
c.v = d
a.v = d
assert n.v.x.v.x.v.x.txt == "c"