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

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

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

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

b = A("b")
k = B("k")
f = C("f")
l = D("l")
e = B("e")
a = A("a")
d = D("d")
h = A("h")
j = B("j")

b.p = l
b.t = l
b.q = k
k.t = f
f.t = a
l.r = f
l.y = d
l.p = d
l.v = j
e.t = f
a.p = d
a.t = d
a.q = k
d.r = f
d.y = l
d.p = l
d.v = k
h.p = d
h.t = d
h.q = k
j.t = f
assert e.t.t.p.r.t.t.r.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: B = None
        self.t: D = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
f = C("f")
l = D("l")
e = B("e")
a = A("a")
d = D("d")
h = A("h")
j = B("j")

b.p = l
b.t = l
b.q = k
k.t = f
f.t = a
l.r = f
l.y = d
l.p = d
l.v = j
e.t = f
a.p = d
a.t = d
a.q = k
d.r = f
d.y = l
d.p = l
d.v = k
h.p = d
h.t = d
h.q = k
j.t = f
assert e.t.t.p.r.t.t.r.t.p.txt == "d"