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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: F = None
        self.o: F = None
        self.v: B = None
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
b = C("b")
f = D("f")
d = E("d")
e = F("e")
h = D("h")

n.r = g
n.q = e
g.o = h
b.p = n
b.o = g
f.r = n
f.x = e
f.o = e
f.v = g
f.w = b
d.r = n
d.v = n
d.t = e
d.x = b
e.r = d
h.r = n
h.x = e
h.o = e
h.v = g
h.w = b
assert h.v.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: F = None
        self.o: F = None
        self.v: B = None
        self.w: C = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
b = C("b")
f = D("f")
d = E("d")
e = F("e")
h = D("h")

n.r = g
n.q = e
g.o = h
b.p = n
b.o = g
f.r = n
f.x = e
f.o = e
f.v = g
f.w = b
d.r = n
d.v = n
d.t = e
d.x = b
e.r = d
h.r = n
h.x = e
h.o = e
h.v = g
h.w = b
assert h.v.o.v.o.txt == "h"