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

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

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

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

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

f.o = n
f.x = c
h.q = n
b.p = l
b.u = n
n.o = l
n.y = c
n.t = b
n.p = f
l.o = n
l.y = h
l.t = b
l.p = f
a.o = n
a.x = h
c.q = l
assert b.p.o.y.q.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

f.o = n
f.x = c
h.q = n
b.p = l
b.u = n
n.o = l
n.y = c
n.t = b
n.p = f
l.o = n
l.y = h
l.t = b
l.p = f
a.o = n
a.x = h
c.q = l
assert b.p.o.y.q.o.p.o.txt == "n"