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

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

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

class D:
    def __init__(self, txt: str):
        self.y: F = None
        self.r: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: C = None
        self.y: D = None
        self.z: D = None
        self.v: F = None
        self.txt = txt

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

h = A("h")
j = B("j")
g = C("g")
n = D("n")
c = E("c")
d = F("d")
i = C("i")

h.p = i
j.p = d
j.x = n
g.p = c
n.y = d
n.r = c
c.t = n
c.y = n
c.z = n
c.q = i
c.v = d
d.t = h
i.p = c
assert i.p.v.t.p.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: F = None
        self.r: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.q: C = None
        self.y: D = None
        self.z: D = None
        self.v: F = None
        self.txt = txt

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

h = A("h")
j = B("j")
g = C("g")
n = D("n")
c = E("c")
d = F("d")
i = C("i")

h.p = i
j.p = d
j.x = n
g.p = c
n.y = d
n.r = c
c.t = n
c.y = n
c.z = n
c.q = i
c.v = d
d.t = h
i.p = c
assert i.p.v.t.p.p.q.p.txt == "c"