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

class B:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

n = A("n")
e = B("e")
b = C("b")
c = D("c")
j = E("j")
f = F("f")
d = G("d")

n.o = b
n.y = d
e.y = f
b.z = n
b.x = f
b.t = j
c.p = e
c.u = n
c.x = f
j.t = d
j.s = b
f.p = e
d.t = c
assert d.t.x.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: G = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

n = A("n")
e = B("e")
b = C("b")
c = D("c")
j = E("j")
f = F("f")
d = G("d")

n.o = b
n.y = d
e.y = f
b.z = n
b.x = f
b.t = j
c.p = e
c.u = n
c.x = f
j.t = d
j.s = b
f.p = e
d.t = c
assert d.t.x.p.y.p.y.txt == "f"