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

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

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

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

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

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

b = A("b")
j = B("j")
a = C("a")
f = D("f")
h = E("h")
i = F("i")
g = D("g")
c = D("c")
e = D("e")

b.p = g
j.o = c
j.q = b
a.v = i
a.x = i
a.r = i
f.p = b
f.x = b
h.x = b
i.p = a
g.p = b
g.x = b
c.p = b
c.x = b
e.p = b
e.x = b
assert h.x.p.p.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

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

b = A("b")
j = B("j")
a = C("a")
f = D("f")
h = E("h")
i = F("i")
g = D("g")
c = D("c")
e = D("e")

b.p = g
j.o = c
j.q = b
a.v = i
a.x = i
a.r = i
f.p = b
f.x = b
h.x = b
i.p = a
g.p = b
g.x = b
c.p = b
c.x = b
e.p = b
e.x = b
assert h.x.p.p.p.x.p.txt == "g"