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

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.q: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

b.q = f
b.x = h
b.o = i
f.t = c
f.q = h
f.x = i
h.p = f
i.v = f
i.z = b
i.x = b
c.r = g
c.p = f
c.v = i
g.u = c
assert b.o.v.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: C = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.q: C = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

b.q = f
b.x = h
b.o = i
f.t = c
f.q = h
f.x = i
h.p = f
i.v = f
i.z = b
i.x = b
c.r = g
c.p = f
c.v = i
g.u = c
assert b.o.v.q.p.txt == "f"