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

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

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

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

b = A("b")
g = B("g")
n = C("n")
f = D("f")
l = B("l")
i = C("i")
h = D("h")
c = A("c")
k = C("k")

b.q = c
b.x = c
b.t = k
b.v = k
g.w = l
g.v = i
g.r = k
n.o = i
f.t = h
f.p = b
l.w = g
l.v = k
l.r = k
i.o = k
h.t = f
h.p = c
c.q = b
c.x = b
c.t = k
c.v = n
k.o = i
assert f.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: A = None
        self.t: C = None
        self.v: C = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
n = C("n")
f = D("f")
l = B("l")
i = C("i")
h = D("h")
c = A("c")
k = C("k")

b.q = c
b.x = c
b.t = k
b.v = k
g.w = l
g.v = i
g.r = k
n.o = i
f.t = h
f.p = b
l.w = g
l.v = k
l.r = k
i.o = k
h.t = f
h.p = c
c.q = b
c.x = b
c.t = k
c.v = n
k.o = i
assert f.t.t.t.t.txt == "f"