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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: E = None
        self.p: F = None
        self.q: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: C = None
        self.s: F = None
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

e = A("e")
j = B("j")
h = C("h")
d = D("d")
i = E("i")
b = F("b")

e.p = b
j.u = e
j.y = i
j.p = b
j.q = d
h.p = j
h.v = e
d.x = e
d.r = e
i.x = h
i.t = h
i.p = h
i.s = b
i.u = d
b.t = h
b.s = j
assert b.t.v.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: E = None
        self.p: F = None
        self.q: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.t: C = None
        self.s: F = None
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

e = A("e")
j = B("j")
h = C("h")
d = D("d")
i = E("i")
b = F("b")

e.p = b
j.u = e
j.y = i
j.p = b
j.q = d
h.p = j
h.v = e
d.x = e
d.r = e
i.x = h
i.t = h
i.p = h
i.s = b
i.u = d
b.t = h
b.s = j
assert b.t.v.p.t.p.txt == "j"