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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
k = C("k")
g = D("g")
e = E("e")
d = F("d")
f = G("f")

c.y = k
c.x = l
c.s = l
c.p = g
l.q = f
l.r = f
k.u = e
k.t = c
k.q = g
k.v = l
k.z = d
g.p = c
e.u = l
d.r = f
f.x = c
f.p = d
assert d.r.p.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.p: D = None
        self.s: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
k = C("k")
g = D("g")
e = E("e")
d = F("d")
f = G("f")

c.y = k
c.x = l
c.s = l
c.p = g
l.q = f
l.r = f
k.u = e
k.t = c
k.q = g
k.v = l
k.z = d
g.p = c
e.u = l
d.r = f
f.x = c
f.p = d
assert d.r.p.r.p.r.txt == "f"